<template>
	<view>
		<view style="width: 750rpx;padding: 30rpx;">
			<view v-if="infoList != ''">
				<view style="color: #133267;font-size: 24rpx;">{{ infoList.length }}条建议</view>
				<view class="list-box" v-for="(item, index) in infoList" :key="index" @click="goDetail(item.id)">
					<view style="color: #133267;font-size: 32rpx;">{{ item.title }}</view>
					<view><u-icon name="arrow-right" color="#133267" size="32"></u-icon></view>
				</view>
			</view>
			<view style="margin-top: 300rpx;display: flex;justify-content: center;" v-else><u-empty text="暂无数据" mode="list"></u-empty></view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isAuth: 0,
			infoList: []
		};
	},
	onLoad(opt) {
		this.aid = opt.aid;
		this.bid = opt.bid;
		this.getList();
	},
	onShow() {
		this.$u.api.myInfo().then(data => {
			this.isAuth = data.isAuth;
		});
	},
	methods: {
		goDetail(id) {
			if (this.isAuth == 0) {
				uni.showModal({
					title: '授权&注册',
					content: '您好，查看该项需要您提供授权并登陆，并补充相关信息',
					cancelText: '取消',
					confirmText: '确认',
					success(res) {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pagesShop/myInfo/information'
							});
						}
					}
				});
			} else if (this.isAuth == 1) {
				uni.navigateTo({
					url: '/pagesShop/science/detail?id=' + id
				});
			}
		},
		getList() {
			this.$u.api
				.ScientResult({
					aid: this.aid,
					bid: this.bid
				})
				.then(data => {
					this.infoList = data;
				});
		}
	}
};
</script>

<style>
page {
	background-color: #f2f2f6;
}
.list-box {
	width: 690rpx;
	padding: 30rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background-color: #ffffff;
	border-radius: 10rpx;
	margin-top: 20rpx;
}
</style>
